Telegram Group & Telegram Channel
📌 Разбор Python-задачи

Если вы ответил 2 — это ловушка

def func(a, b):
res = a + b

res = func(1, 1)
print(res)


На первый взгляд кажется, что res = 2. Но нет.

➡️ Что происходит

1. Функция func(a, b) складывает a + b и сохраняет в переменную res внутри функции.

2. Но! Функция ничего не возвращает. В Python по умолчанию любая функция без return возвращает None.

3. Следовательно, res = func(1, 1) присваивает None.

4. На экран выводится None.

📎 Пост с задачей

Proglib Academy #буст
Please open Telegram to view this post
VIEW IN TELEGRAM



tg-me.com/proglib_academy/2779
Create:
Last Update:

📌 Разбор Python-задачи

Если вы ответил 2 — это ловушка

def func(a, b):
res = a + b

res = func(1, 1)
print(res)


На первый взгляд кажется, что res = 2. Но нет.

➡️ Что происходит

1. Функция func(a, b) складывает a + b и сохраняет в переменную res внутри функции.

2. Но! Функция ничего не возвращает. В Python по умолчанию любая функция без return возвращает None.

3. Следовательно, res = func(1, 1) присваивает None.

4. На экран выводится None.

📎 Пост с задачей

Proglib Academy #буст

BY Proglib.academy | IT-курсы


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/proglib_academy/2779

View MORE
Open in Telegram


Proglib academy | IT курсы Telegram | DID YOU KNOW?

Date: |

Should I buy bitcoin?

“To the extent it is used I fear it’s often for illicit finance. It’s an extremely inefficient way of conducting transactions, and the amount of energy that’s consumed in processing those transactions is staggering,” the former Fed chairwoman said. Yellen’s comments have been cited as a reason for bitcoin’s recent losses. However, Yellen’s assessment of bitcoin as a inefficient medium of exchange is an important point and one that has already been raised in the past by bitcoin bulls. Using a volatile asset in exchange for goods and services makes little sense if the asset can tumble 10% in a day, or surge 80% over the course of a two months as bitcoin has done in 2021, critics argue. To put a finer point on it, over the past 12 months bitcoin has registered 8 corrections, defined as a decline from a recent peak of at least 10% but not more than 20%, and two bear markets, which are defined as falls of 20% or more, according to Dow Jones Market Data.

Newly uncovered hack campaign in Telegram

The campaign, which security firm Check Point has named Rampant Kitten, comprises two main components, one for Windows and the other for Android. Rampant Kitten’s objective is to steal Telegram messages, passwords, and two-factor authentication codes sent by SMS and then also take screenshots and record sounds within earshot of an infected phone, the researchers said in a post published on Friday.

Proglib academy | IT курсы from fr


Telegram Proglib.academy | IT-курсы
FROM USA